package utility

import (
	"io/ioutil"
	"regexp"
)

func GetDNS() ([]string, error) {
	var ips []string
	resolv, err := ioutil.ReadFile("/etc/resolv.conf")
	if err != nil {
		return ips, err
	}
	reg := regexp.MustCompile(`(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)`)
	ips = reg.FindAllString(string(resolv), -1)
	return ips, err
}